#include "mcirc.h"
#ifdef GUI_APPLICATION

int MCirc::area() const
{
	if( _radius < 0 )
		return -1;
	return 3 * _radius * _radius;
}

bool MCirc::resize(int radius)
{
	if( radius < 0 )
		return false;
	_radius = radius;
	return true;
}

bool MCirc::isInclude(const MCirc &other) const
{
	if( this->isValid() and other.isValid() )
		return _radius > other._radius and
			_center.distanceFrom(other._center) < _radius-other._radius;
	return false;
}

bool MCirc::isBeIncluded(const MCirc &other) const
{
	if( this->isValid() and other.isValid() )
		return _radius < other._radius and
			_center.distanceFrom(other._center) < other._radius-_radius;
	return false;
}

bool MCirc::isCutIn(const MCirc &other) const
{
	if( this->isValid() and other.isValid() )
		return _radius <= other._radius and
			_center.distanceFrom(other._center) == other._radius-_radius;
	return false;
}

bool MCirc::isBeCutIn(const MCirc &other) const
{
	if( this->isValid() and other.isValid() )
		return _radius >= other._radius and
			_center.distanceFrom(other._center) == _radius-other._radius;
	return false;
}

bool MCirc::isCutOutsideOn(const MCirc &other) const
{
	if( this->isValid() and other.isValid() )
		return _center.distanceFrom(other._center) == _radius+other._radius;;
	return false;
}

const MCirc &MCirc::operator=(const MCirc &other)
{
	_center = other._center;
	_radius = other._radius;
	return *this;
}

bool MCirc::operator&(const MCirc &other) const
{
	if( this->isValid() and other.isValid() )
	{
		int radius_dv = _radius - other.radius();
		if( radius_dv < 0 )
			radius_dv = -radius_dv;

		int center_dis = _center.distanceFrom(other._center);

		return center_dis > radius_dv and
			center_dis < _radius + other._radius;
	}
	return false;
}

/*----------------------------------------------------------------------*/

bool MBorderCirc::resize(int radius, int border_width)
{
	if( border_width < 0 )
		return false;
	if( circ.resize(radius) )
	{
		this->border_width = border_width;
		return true;
	}
	return false;
}

bool MBorderCirc::setBorderWidth(int border_width)
{
	if( border_width < 0 )
		return false;
	this->border_width = border_width;
	return true;
}

const MBorderCirc &MBorderCirc::operator=(const MBorderCirc &other)
{
	circ = other.circ;
	border_width = other.border_width;
	return *this;
}


#endif //GUI_APPLICATION
